<style scoped>
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .weui-loadmore_line .weui-loadmore__tips {
    background-color: #eee;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
    width: 44%;
    display: inline-block;
    padding: 5px 3%;
    text-align: right;
  }
  .rj-cell span {
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 50%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cells {
    margin-top: 0;
  }
  .weui-cells_form {
    background: #fbfbfb;
  }
  .weui-cell {
    background: #fff;
  }
  .weui-cells__title {
    text-align: left;
  }
  .oitem {
    padding: 3px;
  }
  .hide {
    display: none;
  }
  #acts {
    font-size: 0;
  }
  #acts span {
    font-size: 14px;
  }
  .halfbtn {
    display: inline-block;
    width: 49%;
  }
  .weui-label {
    text-align: left;
  }

  .weui_uploader_input_wrp {
    float: left;
    position: relative;
    margin-right: 9px;
    margin-bottom: 9px;
    width: 77px;
    height: 77px;
    border: 1px solid #D9D9D9;
  }
  .weui_uploader_hd {
    padding-top: 0;
    padding-right: 0;
    padding-left: 0;
  }
  .weui_uploader_files {
    list-style: none;
  }
  .weui_uploader_input_wrp:before {
    width: 2px;
    height: 39.5px;
  }
  .weui_uploader_input_wrp:before, .weui_uploader_input_wrp:after {
    content: " ";
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    background-color: #D9D9D9;
  }
  .weui_uploader_input {
    position: absolute;
    z-index: 1;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  }
  .weui_uploader_input_wrp:after {
    width: 39.5px;
    height: 2px;
  }
  .weui_uploader_bd {
    overflow: hidden;
  }
  .weui_cell {
    padding: 10px 15px;
    position: relative;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    background: #fff;
  }
  .examine >>> .weui-uploader_files {
    list-style: none;
    overflow-y: hidden;
  }
  .examine >>> .weui-uploader_file {
    float: left;
    margin-right: 9px;
    margin-bottom: 9px;
    width: 79px;
    background: no-repeat 50%;
    background-size: cover;
  }
  .weui-cell_select {
    padding: 0 15px;
  }
</style>
<template>
  <div class="examine">
    <div class="rj-wrap">
      {{title}}
      <a href="javascript:;" @click="$router.back(-1)" style="position: absolute; left: 10px; top: 8px">
        <img src="@/assets/back.png" style="width: 20px" />
      </a>
    </div>
    <div class="weui-cells weui-cells_form">
      <form action="" method="post" id="formid">
        <div class="cellgroup">
          <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">回款登记编号</label></div>
            <div class="weui-cell__bd">
              <input class="weui-input" type="text" readonly :value="baseInfo.code" name="">
            </div>
          </div>
          <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">回款总金额({{baseInfo.currency == 2 ? '美元' : '元'}})</label></div>
            <div class="weui-cell__bd">
              <input class="weui-input" type="text" name="" readonly :value="baseInfo.backamount">
            </div>
          </div>
<!--          <div class="weui-cell">-->
<!--            <div class="weui-cell__hd"><label class="weui-label">预付款抵扣金额(元)</label></div>-->
<!--            <div class="weui-cell__bd">-->
<!--              <input class="weui-input" type="text" name="" readonly :value="baseInfo.prepaid">-->
<!--            </div>-->
<!--          </div>-->
          <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">备注</label></div>
            <div class="weui-cell__bd">
              <input class="weui-input" type="text" name="" readonly :value="baseInfo.remark">
            </div>
          </div>
          <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">申请人</label></div>
            <div class="weui-cell__bd">
              <input class="weui-input" readonly name="" :value="baseInfo.operator">
            </div>
          </div>
          <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">创建时间</label></div>
            <div class="weui-cell__bd">
              <input class="weui-input" readonly type="text" name="" :value="baseInfo.createtime">
            </div>
          </div>
        </div>
        <div class="oitem" v-for="(product, index) in baseInfo.items" :key="product.guid">
          <div class="weui-cells__title">回款明细 {{index + 1}}</div>
          <div class="weui-cell fir">
            <div class="weui-cell__hd"><label class="weui-label">销售订单编号</label></div>
            <div class="weui-cell__bd">
              <input class="weui-input" type="text" name="" readonly="true" :value="product.ordercode">
            </div>
          </div>
          <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">回款金额</label></div>
            <div class="weui-cell__bd">
              <input class="weui-input" type="text" name="" readonly="true" :value="product.amount">
            </div>
          </div>
        </div>
        <div ref="actHtml" class="fixcont">
          <div class="weui-cell">
            <div class="weui-cell__bd">
              <textarea class="weui-textarea" v-model="remark" name="remark" placeholder="请输备注内容" rows="3"></textarea>
            </div>
          </div>
          <div class="weui-btn-area">
            <a class="weui-btn weui-btn_primary halfbtn subbtn" href="javascript:" @click="postForm">确定</a>
            <a class="weui-btn weui-btn_primary halfbtn"  href="javascript:" @click="$router.back(-1)" id="sub">返回</a>
          </div>
        </div>
      </form>
    </div>
    <div id="bmlogs">
      <OperationLogs2 :nodeid="nodeid" :orderid="id" :srguid="''" :departid="baseInfo.departid"></OperationLogs2>
    </div>
  </div>
</template>

<script>
  import wx from 'weixin-js-sdk';
  import OperationLogs2 from '@/components/common/OperationLogs2'

  export default {
    name: 'DelPayback',
    data () {
      return {
        id: '',
        baseInfo: {},
        remark: '',
        wxParams: {},
        nodeid: '',
        annex: '',
        title: ''
      }
    },
    components: {OperationLogs2},
    mounted () {
      //提交操作定位到页面底部
      //$('#bmlogs').css('margin-bottom', this.$refs.actHtml.offsetHeight)

      this.id = this.$route.query.guid;
      this.nodeid = this.$route.query.nodeid;
      this.annex = this.$route.query.annex;
      this.title = this.$route.query.title;
      this.getBaseInfo(this.id, this);

    },
    methods: {
      getBaseInfo: function() {
        // 联网请求
        this.axios({
          method: 'get',
          url: '/pay/Paybackinfo!detail.action',
          params: {guid: this.id}
        }).then((response) => {
          if (response.data.code == 1) {
            this.baseInfo = response.data.msg;
          } else if (response.data.code == 0) {
            this.toastText(response.data.msg);
          } else {
            this.toastError("系统错误");
          }

        })
      },
      postForm: function () {
        let that = this;
        //防止重复提交
        $('.subbtn').attr("disabled",true).css("pointer-events","none");
        //显示提交状态
        $.showLoading("正在提交");

        let postData = {
          guid: this.id,
          options: this.remark,
        };
        postData.nodeid = this.nodeid;

        $.confirm('确定要删除?', function () {
          that.axios({
            method: 'post',
            url: '/pay/Paybackinfo!del.action',
            params: postData
          }).then(response => {
            //恢复提交按钮可点击
            $('.subbtn').attr('disabled', false).css("pointer-events","auto");
          //关闭提交状态
          $.hideLoading();

            if (response.data.code == 1) {
              that.toastSuccess('删除成功!');
              that.$router.push({name: 'Paybacklist'});
            } else if (response.data.msg == 'canotopt') {
              that.toastError('不允许的操作');
            } else {
              that.toastError('系统错误');
            }
          }).catch(function (error) {
            //恢复提交按钮可点击
            $('.subbtn').attr('disabled', false).css("pointer-events","auto");
          //关闭提交状态
          $.hideLoading();
            that.toastError('系统错误');
          });
        })

      },
      openLogs: function() {
        this.$router.push({name: 'OperationLogs2', query: {orderid: this.id, srguid: '', departid: ''}});
      }
    }
  }
</script>
